import mx.utils.Delegate;
/**
	Wrapper for the LocalConnection Object that simplifies sending and recieving data
	between flash movies running on the same host.

	@author Chandler McWilliams
	@version 2005-09-16
*/
dynamic class timber.data.LocalConnectionPipe
{
	private var connection;
	private var name;
	
// ===========================================================
// - CONSTRUCTOR
// ===========================================================
	public function LocalConnectionPipe(aName) {
		name = aName;
		connection = new LocalConnection();
		AsBroadcaster.initialize(this);		
		
		connection.receive = Delegate.create(this, receive);
	}
	
	public function connect() {
		getConnection().connect(name);
	}

// ===========================================================
// - ACCESSORS
// ===========================================================
	public function getConnection() {
		return connection;
	}
	
	public function send() {
		var c = getConnection();
		c.send(name, "receive", arguments);
	}
	
	public function receive(args) {
		var method = args[0];
		args.shift();
		this.broadcastMessage(method, args);
	}

}

